package cn.ad.enumration;



/**
 * Created by Administrator on 2016/7/13.
 */
public enum AdSpaceStatus {

    ADSTATUS_DELETED(-1,"删除"),
    ADSTATUS_RESET(0,"初始"),
    ADSTATUS_VALID(1,"有效");

    private int value;
    private String description;
    private static java.util.HashMap<Integer, String> mappings;

    private synchronized static java.util.HashMap<Integer,String> getMappings(){
        if (mappings==null){
            mappings=new java.util.HashMap<>();
            for (AdSpaceStatus status:AdSpaceStatus.values()) {
                mappings.put(status.value,status.description);
            }
        }
        return mappings;
    }

    AdSpaceStatus(int value, String description) {
        this.value = value;
        this.description = description;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "AdSpaceStatus{" +
                "value=" + value +
                ", description='" + description + '\'' +
                '}';
    }

    public static String forValue(int value){
        return getMappings().get(value);
    }
}
